<template>
  <div class="indexIconBox">
    <Slider :options="options">
        <swiper-slide v-for="(item,index) of pages" :key="index">
          <ul class="iconBox">
            <li v-for="j of item" :key="j.id">
              <div class="iconImg">
                <img :src="j.imgUrl" alt="">
              </div>
              <p class="iconTxt">{{j.desc}}</p>
            </li>
          </ul>
        </swiper-slide>
    </Slider>
    <!-- <ul class="iconBox">
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png" alt="">
        </div>
        <p class="iconTxt">景点门票</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/bd/9f7b9b2b60c1502.png" alt="">
        </div>
        <p class="iconTxt">踏青赏花</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1804/ff/fdf170ee89594b02.png" alt="">
        </div>
        <p class="iconTxt">必游榜单</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1804/5a/13ceb38dcf262f02.png" alt="">
        </div>
        <p class="iconTxt">一日游</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/97/02f5043b51b2102.png" alt="">
        </div>
        <p class="iconTxt">情迷九寨</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/20/831d62d2e1c7be02.png" alt="">
        </div>
        <p class="iconTxt">蓉城七景</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/b6/37560ece9c62b502.png" alt="">
        </div>
        <p class="iconTxt">成都周边</p>
      </li>
      <li>
        <div class="iconImg">
          <img src="//img1.qunarzz.com/piao/fusion/1803/47/c2b659e048b11602.png" alt="">
        </div>
        <p class="iconTxt">亲子游</p>
      </li>
    </ul> -->
  </div>
</template>

<script>
import Slider from '@/components/slider'
export default{
  name: 'HomeIcons',
  components: {
    Slider
  },
  data () {
    return {
      iconList: [{
        id: 10001,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
        desc: '景点门票'
      }, {
        id: 10002,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/bd/9f7b9b2b60c1502.png',
        desc: '踏青赏花'
      }, {
        id: 10003,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1804/ff/fdf170ee89594b02.png',
        desc: '必游榜单'
      }, {
        id: 10004,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1804/5a/13ceb38dcf262f02.png',
        desc: '一日游'
      }, {
        id: 10005,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/97/02f5043b51b2102.png',
        desc: '情迷九寨'
      }, {
        id: 10006,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/20/831d62d2e1c7be02.png',
        desc: '蓉城七景'
      }, {
        id: 10007,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/b6/37560ece9c62b502.png',
        desc: '成都周边'
      }, {
        id: 10008,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/47/c2b659e048b11602.png',
        desc: '亲子游'
      }, {
        id: 10009,
        imgUrl: '//img1.qunarzz.com/piao/fusion/1803/e3/67df61427c8e1302.png',
        desc: '演出'
      }],
      options: {
        autoplay: false,
        loop: false
      }
    }
  },
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="scss" scoped>
@import "~styles/layout.scss";
.indexIconBox{
  background-color: #ffffff;
  padding-bottom: 20px;
    .iconBox{
    @include flex(row);
    justify-content: space-between;
    align-items: top;
    flex-wrap: wrap;
    @include autoHeight(100%,50%);
    li{
      @include autoHeight(25%,25%);
      position: relative;
    }
    .iconImg{
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom:22px;
      padding:10px 10px;
      box-sizing: border-box;
      img{
        display: block;
        margin: 0 auto;
        height: 100%;
      }
    }
    .iconTxt{
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      font-size: 20px;
      text-align: center;
      color: #666;
      @include txtOver();
    }
  }
}
</style>
